package com.cakin.javademo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName: DateDemo2
 * @Description: 转化字符串到日期
 * @Date: 2020/6/16
 * @Author: cakin
 */
public class DateDemo2 {
    public static void main(String[] args) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String strDate = "1983-12-03";
        try {
            // parse:将字符串转为date
            // format:将date转为字符串
            Date parse = simpleDateFormat.parse(strDate);
            System.out.println(parse);
            String format = simpleDateFormat.format(parse);
            System.out.println(format);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
